#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL fa[maxn],a[maxn],siz[maxn];
LL find(LL u)
{
    if(fa[u]!=u) return fa[u]=find(fa[u]);
    return fa[u];
}
void uni(LL x,LL y)
{
    LL u=find(x);LL v=find(y);
    if(u!=v){
        if(siz[u]>siz[v])
        {
            siz[u]+=siz[v];
            fa[v]=u;
        }
        else{
            siz[v]+=siz[u];
            fa[u]=v;
        }
    }
}
int minOperations(vector<int>& nums) {
    for(int i=0;i<nums.size();i++) a[i+1]=nums[i];
    int n=nums.size();
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=n;i++)
    {
        if(a[i]+1==a[i+1]) uni(i,i+1);
    }
    int mx=0;
    for(int i=1;i<=n;i++) mx=max(mx,siz[i]);
    LL ans=n-1-mx;
    return ans;
}
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);

   	return 0;
}
